<template>
  <div>
    <div style="width: 800px;margin: 100px auto;">
      <h1>登录页面</h1>
      <el-form label-width="80px" >
        <el-form-item label="用户名"  >
          <el-input placeholder="请输入用户名" v-model="user.username"  ></el-input>
        </el-form-item>
        <el-form-item label="密码"  >
          <el-input type="password" placeholder="请输入密码" v-model="user.password"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="login()">登录</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  data(){
    return{
      user:{}
    }
  },
  methods:{
    login(){
      let url= "http://localhost:8080/v1/users/login"
      //console.log(this.user)
      this.axios.post(url,this.user).then((reponse)=>{
         console.log(reponse)
        if(reponse.data.code == 1){
          this.$message.success('登录成功！！！')
          this.$router.push('/')
        }else{
          this.$message.error(reponse.data.data)

        }
      })
    }
  }
}
</script>

<style scoped>

</style>
